import React from 'react';
import Switch from 'react-router-dom/Switch';
import { Route } from 'react-router-dom';
import Redirect from 'react-router-dom/Redirect';

import ProductList from 'page/product/index/ProductList.jsx';
import ProductSave from 'page/product/index/ProductSave.jsx';
import ProductDetail from 'page/product/detail/ProductDetail.jsx';
import ProductCategory from 'page/product/category/ProductCategory.jsx';
import ProductCategoryAdd from 'page/product/category/ProductCategoryAdd.jsx';

export default
  class ProductRouter extends React.Component {
  constructor(props) {
    super(props);
  }

  render() {
    return (
      <Switch>
        <Route path="/product/index" component={ProductList} />
        {/* ?表示可选 */}
        <Route path="/product/save/:pid?" component={ProductSave} />
        <Route path="/product/detail/:pid" component={ProductDetail} />
        <Route path="/product-category/index/:categoryId?" component={ProductCategory} />
        <Route path="/product-category/add" component={ProductCategoryAdd} />

        <Redirect exact from="/product" to="/product/index" />
        <Redirect exact from="/product-category" to="/product-category/index" />
      </Switch>
    );
  }
}